// shop page
// ============

define(['page/mobile-bind', 'page/profile/address-edit', 'page/profile/region', 'page/profile/bmi-edit', 'wxshare'], 
function(mobileApp, addressEdit, regionEdit, bmiEdit, wxshare) {
  return {
    init: function(data) {
      this.initPage(data)
    },
    
    initPage: function(data) {
      
      // forbidden wx share
      wxshare.initShare(data.jsConfig, false)
      
      // bind mobileApp
      mobileApp.init(__CTX__, true)

      // bind location edit
      addressEdit.init(__CTX__, true)

      // bind region edit
      regionEdit.init(__CTX__, true)

      // bind bmi edit
      bmiEdit.init(__CTX__, true)
      
      $(document).on('click', '.logout', function() {
        $.confirm('你确定要退出当前账户？', function() {
          var deffer = $.ajax({
            url: __CTX__.root + "/logout",
            type: 'GET',
            dataType: 'json',
            timeout: 1000,
            cache: false
          })
          
          deffer.done(function(response){
        	  if(response.code == 0) {
        		  window.location.href = window.__CTX__.root + "/logout-message"
        	  } else {
        		  console.log(response);
        	  }
          })
        })
      })
    }
  }
})